package com.green.constant.enums;

public enum GenderEnum {
    MALE(0, "男"),
    FEMALE(1, "女"),
    SECRET(2, "保密");

    private final Integer code;
    private final String label;

    GenderEnum(Integer code, String label) {
        this.code = code;
        this.label = label;
    }

    public Integer getCode() {
        return code;
    }

    public String getLabel() {
        return label;
    }

    public static Integer getCodeByLabel(String label) {
        for (GenderEnum genderEnum : GenderEnum.values()) {
            if (genderEnum.getLabel().equals(label)) {
                return genderEnum.getCode();
            }
        }
        return 0;
    }

    public static String getLabelByCode(Integer code) {
        for (GenderEnum genderEnum : GenderEnum.values()) {
            if (genderEnum.getCode().equals(code)) {
                return genderEnum.getLabel();
            }
        }
        return MALE.getLabel();


    }
}
